
$(function(){
	
	listMenu();
});

/**
 * 加载菜单
 * @returns
 */
function listMenu(){
	
	$.getJSON(baseURL + "sys/menu/nav", function(data){
		// 保存权限数据
		//window.permissions = data.permissions;
		localStorage.setItem("permissions", data.permissions);
		// 加载菜单
		var html = template('leftMenu',data);  
        $('#site-menu').append(html);
	});
}

/**
 * 退出
 * @returns
 */
function logout() {
	//删除本地token
    localStorage.removeItem("token");
    //跳转到登录页面
    location.href = baseURL + 'login.html';
}

/**
 * 个人信息
 * @returns
 */
function info() {
	
	layer.open({
	  type: 2,
	  title: '个人信息',
	  area: ['550px', '350px'],
	  fixed: false, //不固定
	  maxmin: true,
	  content: 'index/info.html'
	});
	
}
/**
 * 修改密码
 * @returns
 */
function password2() {
	
	layer.open({
		  type: 2,
		  title: '密码修改',
		  area: ['450px', '250px'],
		  fixed: false, //不固定
		  maxmin: true,
		  content: 'index/password.html'
		});
}
/**
 * 清除所有缓存,不清除token
 * @returns
 */
// $('#cleanCache').click(function(){
function cleanCache(){
	var token = localStorage.getItem("token");
	localStorage.clear(); 
	localStorage.setItem("token", token);
	layer.msg("清除成功！", function(){
		top.location.reload()
	});
}